// pages/public/userident.js
var app = getApp();
var CONFIG = require("../../config/config.js");
var share = require("../../utils/share.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        phone:'',
        dataobj:{},
        imgUrl: CONFIG.API_PIC,
        qr_img:'',
    },
    clickpic(){
        var jiaoyanCode = this.data.imgUrl+this.data.dataobj.qr_img;
        share.sendImage(jiaoyanCode);
    },

    // 点击复制
    copyclick(){
        var that = this;
        wx.setClipboardData({
            data: that.data.dataobj.url,
            success: function (res) {
                wx.showToast({
                    title: '复制成功',
                    icon: 'none',
                    duration: 1500
                })
            },
            fail: function (res) {
                wx.showToast({
                    title: '复制失败',
                    icon: 'none',
                    duration: 1500
                })
            },
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        that.setData({
            phone: options.phone,
        })
        that.certifCode();
    },

    // 认证生成二维码
    certifCode(){
        var that = this;
        wx.showLoading({
            title: '加载中~',
        })
        share.wxRequest('crmapi/User/certifCode', { phone: that.data.phone}, function (res) {
            if(Number(res.data.errcode)==0){
                var data = res.data.data;
                that.setData({
                    dataobj:data,
                    qr_img: that.data.imgUrl+data.qr_img
                })
                // console.log(that.data.qr_img)
            }
            wx.hideLoading();
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})